{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "(tensor([[[[ 0,  1,  2,  3],\n           [ 4,  5,  6,  7],\n           [ 8,  9, 10, 11],\n           [12, 13, 14, 15]],\n \n          [[16, 17, 18, 19],\n           [20, 21, 22, 23],\n           [24, 25, 26, 27],\n           [28, 29, 30, 31]],\n \n          [[32, 33, 34, 35],\n           [36, 37, 38, 39],\n           [40, 41, 42, 43],\n           [44, 45, 46, 47]]],\n \n \n         [[[48, 49, 50, 51],\n           [52, 53, 54, 55],\n           [56, 57, 58, 59],\n           [60, 61, 62, 63]],\n \n          [[64, 65, 66, 67],\n           [68, 69, 70, 71],\n           [72, 73, 74, 75],\n           [76, 77, 78, 79]],\n \n          [[80, 81, 82, 83],\n           [84, 85, 86, 87],\n           [88, 89, 90, 91],\n           [92, 93, 94, 95]]]]),\n torch.Size([2, 3, 4, 4]))"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = torch.arange(96).reshape((2, 3, 4, 4))\n",
    "arr,arr.shape"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "data": {
      "text/plain": "(tensor([[[[ 0, 16, 32],\n           [ 4, 20, 36],\n           [ 8, 24, 40],\n           [12, 28, 44]],\n \n          [[ 1, 17, 33],\n           [ 5, 21, 37],\n           [ 9, 25, 41],\n           [13, 29, 45]],\n \n          [[ 2, 18, 34],\n           [ 6, 22, 38],\n           [10, 26, 42],\n           [14, 30, 46]],\n \n          [[ 3, 19, 35],\n           [ 7, 23, 39],\n           [11, 27, 43],\n           [15, 31, 47]]],\n \n \n         [[[48, 64, 80],\n           [52, 68, 84],\n           [56, 72, 88],\n           [60, 76, 92]],\n \n          [[49, 65, 81],\n           [53, 69, 85],\n           [57, 73, 89],\n           [61, 77, 93]],\n \n          [[50, 66, 82],\n           [54, 70, 86],\n           [58, 74, 90],\n           [62, 78, 94]],\n \n          [[51, 67, 83],\n           [55, 71, 87],\n           [59, 75, 91],\n           [63, 79, 95]]]]),\n torch.Size([2, 4, 4, 3]))"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = arr.transpose(1, 3)\n",
    "arr, arr.shape"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "(tensor([[ 0, 16, 32],\n         [ 4, 20, 36],\n         [ 8, 24, 40],\n         [12, 28, 44],\n         [ 1, 17, 33],\n         [ 5, 21, 37],\n         [ 9, 25, 41],\n         [13, 29, 45],\n         [ 2, 18, 34],\n         [ 6, 22, 38],\n         [10, 26, 42],\n         [14, 30, 46],\n         [ 3, 19, 35],\n         [ 7, 23, 39],\n         [11, 27, 43],\n         [15, 31, 47],\n         [48, 64, 80],\n         [52, 68, 84],\n         [56, 72, 88],\n         [60, 76, 92],\n         [49, 65, 81],\n         [53, 69, 85],\n         [57, 73, 89],\n         [61, 77, 93],\n         [50, 66, 82],\n         [54, 70, 86],\n         [58, 74, 90],\n         [62, 78, 94],\n         [51, 67, 83],\n         [55, 71, 87],\n         [59, 75, 91],\n         [63, 79, 95]]),\n torch.Size([32, 3]))"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = arr.flatten(0, 2)\n",
    "arr, arr.shape\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "pytorch",
   "language": "python",
   "display_name": "pytorch"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}